// EG4ROOT.h -- an interface to ROOT for filling the generate
// sim data in a tree, and storing it in a root file
// Created: Sept. 24, 2024 by Asia SUN
// Last modified: Sept. 24, 2024 by Asia SUN

#ifndef EG4ROOT_h
#define EG4ROOT_h

#include <string>

using std::string;

// ROOT class forward declarations
class TFile;
class TTree;
class EG4Data;

class EG4ROOT{
public:
  EG4ROOT();
  virtual ~EG4ROOT();

  virtual void Fill(); ///< fill the tree
  virtual void Finish(); ///< write the tree and close the rootfile

  TFile *rootfile() const{ return fFile; }
  TTree *tree() const{ return fTree; }
  EG4Data *data() const{ return fData; }

protected:
  virtual void Initialize();

  string fROOTFileName;
  TFile *fFile;
  TTree *fTree;
  // data for each event, would be assigned by EG4EventAction per event
  EG4Data *fData;
};

#endif
